#pragma once

namespace cr
{
	template <int BLOCK_SIZE>
	class DataBlock
	{
	public:

		template <typename T>
		T& As()
		{
			return *reinterpret_cast<T*>(m_data);
		}

		template <typename T>
		void Assign(const T& obj)
		{
			CheckSize<T, sizeof(T)>();
			memcpy(m_data, &obj, sizeof(obj));
		}

		void Clear()
		{
			memset(m_data, 0, BLOCK_SIZE);
		}

	private:

		cr::uint8_t		m_data[BLOCK_SIZE];

		template <typename T, size_t sizeT>
		void CheckSize()
		{
			CR_STATIC_ASSERT(sizeof(T) <= BLOCK_SIZE);
		}
	};
}